﻿<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
    CodeBehind="Default.aspx.vb" Inherits="FishTank._Default" %>

<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <asp:ScriptManager ID="AquariumDetailScriptManager" runat="server"></asp:ScriptManager>
    <h2>Welcome to FishTank</h2>
    
    <asp:Accordion ID="DashboardAccordion" runat="server"
        CssClass="accordion"  
        HeaderCssClass="accordionHeader"  
        HeaderSelectedCssClass="accordionHeaderSelected"  
        ContentCssClass="accordionContent"
        FadeTransitions="true">
    <Panes>
        <asp:AccordionPane ID="AccordionPane1" runat="server">
            <Header>Top 10 aquariums</Header>
            <Content>
                <asp:ListView ID="AquariumListView" runat="server" GroupItemCount="5"
                    DataKeyNames="ID" DataSourceID="AquariumSqlDataSource">
                    <GroupTemplate>
                        <tr ID="itemPlaceholderContainer" runat="server">
                            <td ID="itemPlaceholder" runat="server">
                            </td>
                        </tr>
                    </GroupTemplate>
                    <ItemTemplate>
                        <td id="Td1" runat="server">
                            <div class="thumbnail">
                                <a href='/Pages/AquariumDetail.aspx?ID=<%# Eval("ID") %>'>
                                <asp:Image ID="PhotoImage" runat="server"
                                            ImageUrl='<%# GetPhotoThumbPath(CULng(Eval("PhotoID"))) %>'
                                            AlternateText="<%# Bind('Title') %>" />
                                </a>
                            </div>
                            <div class="caption">
                                <a href='/Pages/AquariumDetail.aspx?ID=<%# Eval("ID") %>'>
                                <asp:Label ID="TitleLabel" runat="server" Text="<%# Bind('Title') %>" /><br />
                                Popularity: <asp:Label ID="PopularityLabel" runat="server" Text="<%# Bind('Popularity') %>" />
                                </a>
                            </div>
                        </td>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <table id="Table1" runat="server" class="listView">
                            <tr id="Tr1" runat="server">
                                <td id="Td2" runat="server">
                                    <table ID="groupPlaceholderContainer" runat="server" border="0">
                                        <tr ID="groupPlaceholder" runat="server">
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr id="Tr2" runat="server">
                                <td id="Td3" runat="server">
                                </td>
                            </tr>
                        </table>
                    </LayoutTemplate>
                </asp:ListView>
            </Content>
        </asp:AccordionPane>
        <asp:AccordionPane ID="AccordionPane2" runat="server">
            <Header>Favorite fish</Header>
            <Content>
                <asp:ListView ID="FishListView" runat="server" GroupItemCount="5"
                    DataKeyNames="ID" DataSourceID="FishSqlDataSource">
                    <GroupTemplate>
                        <tr ID="itemPlaceholderContainer" runat="server">
                            <td ID="itemPlaceholder" runat="server">
                            </td>
                        </tr>
                    </GroupTemplate>
                    <ItemTemplate>
                        <td id="Td1" runat="server">
                            <div class="thumbnail">
                                <a href='/Pages/FishDetail.aspx?ID=<%# Eval("ID") %>'>
                                <asp:Image ID="PhotoImage" runat="server"
                                            ImageUrl='<%# GetPhotoThumbPath(CULng(Eval("PhotoID"))) %>'
                                            AlternateText="<%# Bind('Title') %>" />
                                </a>
                            </div>
                            <div class="caption">
                                <a href='/Pages/FishDetail.aspx?ID=<%# Eval("ID") %>'>
                                <asp:Label ID="TitleLabel" runat="server" Text="<%# Bind('Title') %>" /><br />
                                Popularity: <asp:Label ID="PopularityLabel" runat="server" Text="<%# Bind('Popularity') %>" />
                                </a>
                            </div>
                        </td>
                    </ItemTemplate>
                    <LayoutTemplate>
                        <table id="Table1" runat="server" class="listView">
                            <tr id="Tr1" runat="server">
                                <td id="Td2" runat="server">
                                    <table ID="groupPlaceholderContainer" runat="server" border="0">
                                        <tr ID="groupPlaceholder" runat="server">
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr id="Tr2" runat="server">
                                <td id="Td3" runat="server">
                                </td>
                            </tr>
                        </table>
                    </LayoutTemplate>
                </asp:ListView>
            </Content>
        </asp:AccordionPane>
        <asp:AccordionPane ID="AccordionPane3" runat="server">
            <Header>Latest questions</Header>
            <Content>
                <asp:GridView ID="QuestionListGrid" runat="server"
                    AutoGenerateColumns="False" DataSourceID="QuestionSqlDataSource"
                    Width="100%" CssClass="gridView">

                    <AlternatingRowStyle CssClass="gridAltRowView" />

                    <Columns>
                         <asp:TemplateField HeaderText="Member">
                            <ItemTemplate>  
                                <a href="/Pages/MemberDetail.aspx?UserName=<%# Eval("MemberUserName") %>">
                                    <asp:Image ID="ProfilePhoto" runat="server"
                                               ImageUrl='<%# GetPhotoThumbPath(CStr(Eval("MemberPhoto"))) %>'
                                               AlternateText="<%# Bind('MemberUserName') %>"/>
                                </a>
                                <p><asp:Label ID="Label1" runat="server" Text="<%# Bind('MemberFullName') %>"></asp:Label></p>
                            </ItemTemplate>
                            <ItemStyle Width="96" Height="64" CssClass="centered" />
                        </asp:TemplateField>
                        <asp:HyperLinkField DataNavigateUrlFields="ID" 
                            DataNavigateUrlFormatString="/Pages/QuestionDetail.aspx?ID={0}" DataTextField="Title" 
                            HeaderText="Question Title" />
                        <asp:BoundField DataField="TotalAnswers" HeaderText="Answers" 
                            ItemStyle-CssClass="centered" />
                        <asp:BoundField DataField="CreatedDateTime" HeaderText="Created Date" 
                            dataformatstring="{0:MMMM d, yyyy}" ItemStyle-CssClass="centered" />
                    </Columns>
                </asp:GridView>
            </Content>
        </asp:AccordionPane>
    </Panes>
    </asp:Accordion>
    
    <asp:SqlDataSource ID="AquariumSqlDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:fishTankConnection %>" 
        ProviderName="<%$ ConnectionStrings:fishTankConnection.ProviderName %>" 
        SelectCommand="SELECT TOP 10 [ID], [Title], [PhotoID], [Popularity] FROM [AquariumListView] ORDER BY [Popularity] DESC">
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="FishSqlDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:fishTankConnection %>" 
        ProviderName="<%$ ConnectionStrings:fishTankConnection.ProviderName %>" 
        SelectCommand="SELECT TOP 10 [ID], [Title], [ScientificName], [PhotoID], [Popularity] FROM [FishListView] ORDER BY [Popularity] DESC">
    </asp:SqlDataSource>

    <asp:SqlDataSource ID="QuestionSqlDataSource" runat="server" 
        ConnectionString="<%$ ConnectionStrings:fishTankConnection %>" 
        ProviderName="<%$ ConnectionStrings:fishTankConnection.ProviderName %>" 
        SelectCommand="SELECT TOP 10 [ID], [Title], [MemberUserName], [MemberPhoto], [MemberFullName], [TotalAnswers], [CreatedDateTime] FROM [QuestionListView] ORDER BY [CreatedDateTime] DESC">
    </asp:SqlDataSource>
</asp:Content>
